Make the master fd belonging to the pty pair non-blocking. Writes were blocking
authoremellor@leeni.uk.xensource.com <emellor@leeni.uk.xensource.com>
Tue, 6 Dec 2005 16:40:43 +0000 (16:40 +0000)
committeremellor@leeni.uk.xensource.com <emellor@leeni.uk.xensource.com>
Tue, 6 Dec 2005 16:40:43 +0000 (16:40 +0000)
if the console client disconnected before all the data had been written to the
pty, even though the select call had indicated that the fd was previously
writable.  Reads have been observed exhibiting similar behaviour too.

Closes bug #380.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
tools/console/daemon/io.c

index a26a6560dc797b77aa7c7fe88d91638aabbd8017..1b49f20c23dae8605890c909288ff6d257f47b73 100644 (file)
@@ -180,6 +180,9 @@ static int domain_create_tty(struct domain *dom)
                free(path);
                if (!success)
                        goto out;
+
+               if (fcntl(master, F_SETFL, O_NONBLOCK) == -1)
+                       goto out;
        }
 
        return master;